package com.zklh.leetcode.dfs;

import com.zklh.leetcode.tree.model.TreeNode;

/**
 * 二叉树展开为链表
 *
 * @author 坐看落花
 * @version 1.0
 * @date 2022/5/26 16:56
 */
public class Solution114 {
    public void flatten(TreeNode root) {
        flattenAndReturnLast(root);
    }

    private TreeNode flattenAndReturnLast(TreeNode root) {


        TreeNode leftLast = flattenAndReturnLast(root.left);

        TreeNode rightLast = flattenAndReturnLast(root.right);

        if (leftLast == null) {
            return rightLast != null ? rightLast : root;
        }

        if (rightLast == null) {
            
        }


        return rightLast;
    }
}
